<template>
  <svg
    class="svg-icon"
    :style="{
      width: width,
      height: height
    }"
  >
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script>
export default {
  name: 'svgIcon',
  props: {
    icon: {
      //svg图标名称
      type: String,
      required: true
    },
    width: {
      //svg宽度
      type: [Number, String]
    },
    height: {
      //svg高度
      type: [Number, String]
    }
  },
  computed: {
    iconName() {
      return `#icon-${this.icon}`;
    }
  }
};
</script>

<style scoped>
.svg-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: currentColor;
  overflow: hidden;
}
</style>
